defmodule ListKit do
	@moduledoc false

	@doc """
	[{a,b,c},{a,b,c}]
	"""
	def keytake(list, key, pos, default \\ nil) do
		case List.keytake(list, key, pos) do
			nil ->
				{default, list}
			v ->
				v
		end
	end

	def reduce_list([], acc, _fun) do
		acc
	end
	def reduce_list(list, acc, fun) when is_list(list) and is_function(fun, 2) do
		{rest, acc} = fun.(list, acc)
		reduce_list(rest, acc, fun)
	end

	def to_list(v) when is_list(v) do
		v
	end
	def to_list(nil) do
		[]
	end
	def to_list(v) do
		[v]
	end


	def append(nil, list) do
		list
	end
	def append(v, list) when is_list(v) do
		v ++ list
	end
	def append(v, list) do
		[v | list]
	end

end
